#ifndef CS_SESSION_H
#define CS_SESSION_H

#include <boost\asio.hpp>
#include <boost\bind.hpp>
#include <boost\enable_shared_from_this.hpp>

#include <interface\session_interface.h>
#include "dispatcher.h"
#include <utils\logger.h>
#include "message.h"

namespace cs
{
	class session:
		public session_interface,
		public boost::enable_shared_from_this<session>
	{
	public:
		session(boost::asio::io_service& io_service);
		boost::asio::ip::tcp::socket& socket();
		void start();
		void deliver(const message& msg);
		void handle_read_header(const boost::system::error_code& error);
		void handle_read_body(const boost::system::error_code& error);
		void handle_write(const boost::system::error_code& error);
	
	private:
		address address_;
		boost::asio::ip::tcp::socket socket_;
	//	registry& registry_;
		message read_msg_;
	//	registry::message_queue_t write_msgs_;
	};
}
#endif /* CS_SESSION_H */